<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<link rel="stylesheet" media="screen" href="css/docs.css"/>
<script type="text/javascript" src="${ctx}/js/global_util.js"></script>
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>

<!-- jQplot SETUP END -->

<h1 class="page-title">个人所得税管理-方案修改</h1>


<div class="container_12 clearfix leading">

    <form class="form has-validation" id="post_form" name="post_form">
        <div class="clear"></div>
        <h5>个税方案：<strong>
            <input name="salaryIndividualTax.title" id="salaryIndividualTax_title" value="${salaryIndividualTax.title}"
                   type="text" style="width:30%"></strong></h5>

        <div class="container_12 clearfix" style="margin-left:0px; margin-right:0px">

            <div class="portlet grid_12" style="padding-bottom:20px">
                <header>
                    <h6>缴费基数</h6>

                </header>

                <section>
                    <table class="display" id="example" style="clear:none">
                        <thead>
                        <tr>
                            <th>是否除去四金</th>
                            <th>挂钩数据</th>
                            <th>手动输入</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr class="gradeA">
                            <td><input name="salaryIndividualTax.removeInsurance" type="radio"
                                       id="isRemoveInsurance_yes" value="true"/>
                                是
                                <input type="radio" name="salaryIndividualTax.removeInsurance"
                                       id="isRemoveInsurance_no" value="false"/>
                                否
                            </td>
                            <td><select id="linkedDataType" name="salaryIndividualTax.linkedDataType"
                                        style="opacity: 0;">
                                <option value="no_linked">无挂钩数据(手动输入)</option>
                                <option value="employee_base_salary">和员工基本工资挂钩</option>
                                <option value="employee_performance">和员工绩效奖金挂钩</option>
                                <option value="employee_salary_performance">和员工基本工资+绩效奖金挂钩</option>
                                <option value="salary_framework">和薪资框架中的项目总和挂钩</option>
                            </select></td>
                            <td><strong>
                                <input name="salaryIndividualTax.costBase" id="salaryIndividualTax_costBase"
                                       value="${salaryIndividualTax.costBase}" type="text" style="width:60px"/> 元
                            </strong></td>
                        </tr>
                        </tbody>
                    </table>
                </section>
            </div>
            <input type="hidden" name="salaryIndividualTax.id" value="${salaryIndividualTax.id}"/>
            <input type="hidden" name="salaryIndividualTax.organization.id" value="${organizationId}"/>
        </div>
    </form>
</div>


<div class="clear"></div>
<div class="container_12 clearfix leading" style=" padding-left:20px">

    <div class="form-action clearfix">
        <p>
            <a class="button" href="javascript:void(0)" onclick="checkForm();"><span
                    style="background:url(${ctx}/images/img/page_edit.png)"
                    class="icon">&nbsp;</span>确定提交</a>
            <a class="button" href="#salary/individual_tax_main.xhtml"><span
                    style="background:url(${ctx}/images/img/arrow_undo.png)"
                    class="icon">&nbsp;</span>返回</a></p>
    </div>

</div>

<script type="text/javascript">

    function checkForm() {
        if (checkNull($("#salaryIndividualTax_title").attr("value"))) {
            alert("方案名称不能为空");
            return false;
        }
        if($("#linkedDataType").val()=='no_linked') {
            if ($("#salaryIndividualTax_costBase").val() == null
                || $("#salaryIndividualTax_costBase").val().trim() == ""
                || isNaN($("#salaryIndividualTax_costBase").val())) {
                alert("方案金额填写不正确");
                return false;
            }
        }

        var url = "${ctx}/salary/individual_tax_save.xhtml";
        $.ajax(url, {
            type:"POST",
            data:$("#post_form").serialize(),
            dataType:"html",
            cache:false,
            success:function(a) {
                return pageDownloaded(a, url)
            },
            complete:function(b) {
            }
        });
    }

    $(document).ready(function() {

        var linkedDataType = "${salaryIndividualTax.linkedDataType}";
        $("#linkedDataType").val(linkedDataType);
        var isRemoveInsurance =${salaryIndividualTax.removeInsurance};
        if (isRemoveInsurance) {
            $("#isRemoveInsurance_yes").attr("checked", true);
        } else {
            $("#isRemoveInsurance_no").attr("checked", true);
        }
    });
</script>
